// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.warehouse.viewers;

import org.dengues.core.warehouse.ENavNodeType;
import org.dengues.core.warehouse.ENodeCategoryName;
import org.dengues.warehouse.models.WarehouseNode;
import org.eclipse.jface.viewers.ViewerSorter;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * $Id: Dengues.epf 2007-12-12 qiang.zhang $
 * 
 */
public class WarehouseViewNameSorter extends ViewerSorter {

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
     */
    @Override
    public int category(Object element) {
        WarehouseNode object = (WarehouseNode) element;
        ENodeCategoryName categoryName = object.getCategoryName();
        if (object.getNodeType() == ENavNodeType.SYSTEM_FOLDER || object.getNodeType() == ENavNodeType.ELEMENT) {
            switch (categoryName) {
            case BIN:
                return 1000;
            case DATABASE:
                return 210;
            case DATASOURCE:
                return 200;
            case PROCESS:
                return 100;
            case FLATFILE:
                return 220;
            case XMLFILE:
                return 230;
            case WEBSERVICE:
                return 240;
            case TABLE:
                return 211;
            case QUERY:
                return 220;
            case REPORTS:
                return 150;
            default:
                return 1000;
            }
        } else if (object.getNodeType() == ENavNodeType.SIMPLE_FOLDER) {
            return 400;
        }
        return 500;
    }
}
